package com.zf.shuashua.bean.advert;

import com.zf.shuashua.api.Store;

import java.io.Serializable;
import java.util.List;

/**
 * 信息流广告配置
 */
public class DrawConfigBean implements Serializable {

    //信息流
    private List<AdvertConfigBean> drawing;
    private int indexDraw = -1;

    /**
     * 顺序执行draw信息流配置
     * @return
     */
    public String getDrawId(){
        if(drawing == null || drawing.size() < 1){
            return "";
        }
        if(drawing.size() == 1){
            return drawing.get(0) == null ? "" : drawing.get(0).getOrigin_id();
        }
        int index = indexDraw + 1 < drawing.size() ? indexDraw + 1 : 0;
        indexDraw = index;
        return drawing.get(index) == null ? "" : drawing.get(index).getOrigin_id();
    }

    /**
     * 顺序执行draw信息流配置
     * @return
     */
    public AdvertConfigBean getAdvertConfig(){
        if(drawing == null || drawing.size() < 1){
            return null;
        }
        if(drawing.size() == 1){
            return drawing.get(0);
        }
        int index = indexDraw + 1 < drawing.size() ? indexDraw + 1 : 0;
        indexDraw = index;
        Store.getInstance().setDrawIndex(index);
        return drawing.get(index);
    }

    public List<AdvertConfigBean> getDrawing() {
        return drawing;
    }

    public void setDrawing(List<AdvertConfigBean> drawing) {
        this.drawing = drawing;
    }

    public int getIndexDraw() {
        return indexDraw;
    }

    public void setIndexDraw(int indexDraw) {
        this.indexDraw = indexDraw;
    }
}
